import './assets/main.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import App from './App.vue'
import router from './router'
import { useUserStore } from '@/stores/user'
import { refreshToken } from './api/userApi'
const app = createApp(App)
const pinia = createPinia()
app.use(pinia.use(piniaPluginPersistedstate))
app.use(router)
app.use(ElementPlus)
app.mount('#app')
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.component(key, component)
}
setInterval(() => {
	const store = useUserStore()
	if (Date.now() - store.accessTokenTime > 1000 * 4) {
		store.accessTokenTime = 0
		store.accessToken = ''
	}
},1000)
